package com.len.entity;

import lombok.Data;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Table(name="node")
@Data
@ToString
public class Node {
    @Id
    @Column(name = "id")
    private Integer id;

    private String label;

    @Column(name = "parent_id")
    private Integer parentId;

    private String name;

    private String description;

    @Column(name = "oss_name")
    private String ossName;

    @Column(name = "oss_description")
    private String ossDescription;

    private String type;

    private String sql;

    @Column(name = "data_source")
    private String dataSource;

    private String output;

    private String template;

    @Column(name = "result_type")
    private String resultType;

    private String status;

    @Column(name = "class_name")
    private String className;

    private String method;

    /**
     * 排序字段
     */
    @Length(min = 1,max = 4, message = "序号长度不对")
    @Column(name = "order_num")
    private Integer orderNum;

    @Column(name = "create_by")
    private String createBy;

    @Column(name = "create_date")
    private Date createDate;

    @Column(name = "update_by")
    private String updateBy;

    @Column(name = "update_date")
    private Date updateDate;

    private List<Node> children=new ArrayList<>();

    public void addChild(Node node){
        children.add(node);
    }


}
